import React, {Component} from 'react';

const DetailData = [
    {id: '01', content: '你好，中国'},
    {id: '02', content: '你好，小哥'},
    {id: '03', content: '你好，未来的自己'},
]

class Detail extends Component {
    render() {
        console.log('Detail',this.props)
        // 接收params参数
        // const {id, title} = this.props.match.params;

        // 接收search参数
        const {search} = this.props.location;
        // const params = new URLSearchParams(search);
        // console.log(" URLSearchParams - ", params.get("id"))
        // const {id, title} = qs.parse(search);

        // 接收state参数
        const {id, title} = this.props.location.state || {}
        const findResult = DetailData.find((detailObj) => {
            return detailObj.id === id;
        }) || {}
        return (
            <ul>
                <li>ID：{id}</li>
                <li>TITLE：{title}</li>
                <li>CONTENT：{findResult.content}</li>
            </ul>
        );
    }
}

export default Detail;